<?php

class Role {
    function Role() {
    }
    public function execute() {
    	global $page;
    	$page->success = true;
    	$page->root = $this->getRoleList($page->start,$page->limit);
    }
    
    public function getRoleList($start,$limit) {
    	$cond = array(
    		'offset'=>$start,
    		'size' =>$limit
    	);
    	$rs = DB::LimitQuery("td_role",$cond);
    	$arr = array();
    	$i=0;
    	foreach($rs as $x) {
    		$tem = array(
    			'id'=>$x[id],
    			'roleName'=>$x[role_name],
    			'remark' =>$x[remark],
    			'startDay'=>$x[start_day],
    			'endDay'=>$x[end_day]
    		);
    		$arr[$i++] = $tem;
    	}
    	return $arr;
    	
    }
    
    public function addRole() {
    	$arr = array(
    		'role_name'=>$_POST[roleName],
    		'remark'=>$_POST[remark],
    		'start_day'=>$_POST[startDay],
    		'end_day'=>$_POST[endDay]
    	);
    	DB::SaveTableRow('td_role',$arr);
    }
    
    
    public function deleteRole() {
    	$arr = explode(",",$_POST[ids]);
    	foreach($arr as $k) {
    		$t = array('id'=>$k);
    		DB::DelTableRow('td_role',$t);
    	}
    	
    }
    
}
?>